package java网络编程;

import java.io.IOException;
import java.net.*;

/**
 * @author coderFu
 * @create 2022/2/25
 * UDP 发送方
 */
public class Sender {

    public static void main(String[] args) throws IOException {
        String data = "Java is the best language";

        //创建发送端对象
        DatagramSocket sender = new DatagramSocket(10011);

        DatagramPacket datagramPacket = new DatagramPacket(data.getBytes(), data.getBytes().length, InetAddress.getLocalHost(),10010);

        // 发送数据
        sender.send(datagramPacket);
        sender.close();
    }
}
